# 解决乱码：codecs
import codecs

# 打开文件
file = codecs.open('test.txt', 'r', 'utf-8')

# 操作文件
# 1. 读取全部，返回字符串
# content = file.read()

# 2. 读取一行，返回字符串
# line = file.readline()


# while line != '':
#     print(line,end='')
#     line = file.readline()

# 3. 读取一行，返回列表
lines = file.readlines()

print("type(lines):", type(lines))

print(lines)
for line in lines:
    print(line, end='')
# 关闭文件
file.close()
